from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
from users.models import BasicUser


class Collage(models.Model):
    id = models.CharField(max_length=200, primary_key=True, verbose_name="学院id")
    collage_name = models.CharField(max_length=30, verbose_name="学院名称")

    def __str__(self):
        return self.collage_name


class Place(models.Model):
    id = models.CharField(max_length=200, primary_key=True, verbose_name="地点id")
    place_name = models.CharField(max_length=50, verbose_name="教学地点名称")

    def __str__(self):
        return self.place_name


class Course(models.Model):
    id = models.CharField(max_length=200, primary_key=True, verbose_name="课程id")
    course_name = models.CharField(max_length=30, verbose_name="课程名称")
    place_id = models.CharField(max_length=200, verbose_name="上课地点")
    teach_user_id = models.CharField(max_length=200, verbose_name="教授课程老师的id")
    collage_id = models.CharField(max_length=200, verbose_name="课程所属院校的id")
    max_people = models.IntegerField(verbose_name="最大人数")
    now_people = models.IntegerField(default=0, verbose_name="当前人数")

    def __str__(self):
        return self.course_name


class Choose(models.Model):
    id = models.AutoField(primary_key=True)
    user_id = models.CharField(max_length=200, verbose_name="用户id")
    course_id = models.CharField(max_length=200, verbose_name="课程id")

    def __str__(self):
        return "用户：" + BasicUser.objects.filter(user_id=self.user_id).values()[0]["real_name"] + \
               "，课程：" + Course.objects.filter(id=self.course_id).values()[0]["course_name"]
